﻿CREATE PROCEDURE [dbo].[kp_DmNganhSelectByHoSoSttRec]
	@Stt_Rec nvarchar(15)
AS
	SELECT 
		CASE WHEN [Stt_Rec] IS NULL THEN 0 ELSE 1 END Choice
		,ISNULL([Stt_Rec],@Stt_Rec) [Stt_Rec]      
		,ISNULL([Loai],1) [Loai]
		,CASE ISNULL([Loai],1) WHEN 1 THEN N'Thêm mới' WHEN 2 THEN N'Sửa' WHEN 3 THEN N'Xóa' END
		,T2.*
		,T3.Ten_Nhom
  FROM  (Select * from  [tblNganhHSo] Where Stt_Rec=@Stt_Rec) T1 
	right join tblDmNganh T2 on T2.Ma_Nganh=T1.Ma_Nganh
	Inner join tblDmNhomNganh T3 on T3.Ma_Nhom=T2.Ma_Nhom
RETURN 0;